package com.kim.nidoya.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabWidget;

import com.kim.nidoya.R;

@SuppressWarnings("deprecation")
public class TabMainActivity extends android.app.TabActivity {
	/** Called when the activity is first created. */
	private TabHost tabhost;
	private TabWidget tabWidget;
	private Intent intent1, intent2, intent3, intent4;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_layout);
		tabhost = getTabHost();
		tabWidget = tabhost.getTabWidget();

		intent1 = new Intent(TabMainActivity.this, PersonalCenterGroup.class);
		tabhost.addTab(tabhost
				.newTabSpec("one")
				.setIndicator("",
						getResources().getDrawable(R.drawable.personal_center))
				.setContent(intent1));

		intent2 = new Intent(TabMainActivity.this, MediaCenterActivity.class);
		tabhost.addTab(tabhost
				.newTabSpec("two")
				.setIndicator("",
						getResources().getDrawable(R.drawable.media_zone))
				.setContent(intent2));

		intent3 = new Intent(TabMainActivity.this, Test_02.class);
		tabhost.addTab(tabhost
				.newTabSpec("three")
				.setIndicator("",
						getResources().getDrawable(R.drawable.agent_and_join))
				.setContent(intent3));

		intent4 = new Intent(TabMainActivity.this, SettingsGroup.class);
		tabhost.addTab(tabhost
				.newTabSpec("four")
				.setIndicator("",
						getResources().getDrawable(R.drawable.settings))
				.setContent(intent4));

		// 获取当前activity
		// getLocalActivityManager().getActivity(tabhost.getCurrentTabTag());
		// 改变tabWidget的选中状态
		for (int i = 0; i < tabWidget.getChildCount(); i++) {

			Object v = tabWidget.getChildAt(i);
			if (v instanceof RelativeLayout) {
				RelativeLayout vvv = (RelativeLayout) v;
				vvv.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.tab_host_check_selector));

			}
		}

	}
	
	@Override
	public void onBackPressed() {
		finish();
	}
}
